﻿using System.IO;
using System.Windows;
using System.Windows.Documents;

namespace Utils.Extensions
{
	public static class FlowDocumentExtension
	{
		public static void Save(this FlowDocument document, string fileName)
		{
			using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
			{
				TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
				range.Save(fileStream, DataFormats.Xaml);
			}
		}

		public static void Load(this FlowDocument document, string fileName)
		{
			using (FileStream fileStream = new FileStream(fileName, FileMode.Open))
			{
				TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
				range.Load(fileStream, DataFormats.Xaml);
			}
		}
	}
}
